<%@page import="fr.uniscol.model.BaseAnneeScolaire"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<style>
<!--
	td.base-icon{
		background-image: url("/UniscolSpring/resources/img/base.png");
		background-repeat: no-repeat;
		background-position: 50% 50%;
	}
-->
</style>
<script type="text/javascript">
<!--
	function supprimer(annee){
		$(".modal-title").html("Supprimer l'année scolaire " + annee + " ?");
		$(".modal-body").html("Toutes les données associées à l'année " + annee + " seront perdues. <br/>Etes-vous sur(e) de vouloir supprimer cette année ?");
		$("#btnSupprimer").click(function(){
			location = 'base.delete?annee=' + annee;
		});
		$("#deleteBaseConfirm").modal("show");
	}
//-->
</script>
<div class="container-fluid">
	<div class="row">
		<div class="col-sm-offset-1 col-md-6">
			<h4>Bases</h4>
			<input type="button" value="Créer une nouvelle année scolaire" class="btn btn-primary btn-md" onClick="javascript:location='<c:url value='base.creation'/>'"/>
			<table class="table table-striped table-hover">
				<thead>
				<tr>
					<th></th>
					<th>Année</th>
					<th class="buttons">
					</th>
				</tr>
				</thead>
				<tbody>
					<c:forEach items="${bases}" var="base">
					<tr>
						<td class="base-icon"><img src="<c:url value="/resources/img/base.png"/>" alt="Base" /></td>
						<td>${base.annee}<br/>
							Du: <fmt:formatDate value="${base.calendrier.debut.time}" pattern="dd/MM/yyyy"/><br/> 
							Au: <fmt:formatDate value="${base.calendrier.fin.time}" pattern="dd/MM/yyyy" />
						</td>
						<td class="buttons">
									<input type="button" value="Modifier" class="btn btn-primary btn-sm"/>
									<input type="button" value="Clôturer" class="btn btn-primary btn-sm"/>
									<input type="button" value="Archiver" class="btn btn-primary btn-sm"/>
									<input type="button" value="Importer" class="btn btn-primary btn-sm" onClick="javascript:location='imports?annee=${base.annee}'"/>
									<input type="button" value="Synchroniser" class="btn btn-primary btn-sm" onClick="javascript:location='synchroniser?annee=${base.annee}'"/>
									<input type="button" value="Exporter" class="btn btn-primary btn-sm"/>
									<input type="button" value="Détruire" class="btn btn-primary btn-sm" onClick="javascript:supprimer(${base.annee})"/>
							</ul>
						</td>
					</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
</div>

<!-- MODAL Suppression de la base -->
<div id="deleteBaseConfirm" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Supprimer la base ?</h4>
      </div>
      <div class="modal-body">

      </div>
      <div class="modal-footer">
        <button type="button" id="btnAnnuler" class="btn btn-default" data-dismiss="modal">Annuler</button>
        <button id="btnSupprimer" type="button" class="btn btn-primary">Supprimer</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->